//
//  HZL_LocationCollectionViewCell.m
//  B_Project
//
//  Created by dllo on 15/11/29.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_LocationCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface HZL_LocationCollectionViewCell ()
@property (nonatomic, retain) UIImageView *imgView;
@property (nonatomic, retain) UILabel *titleLabel;
@end
@implementation HZL_LocationCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // 创建控件
        // 图片
        self.imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imgView];
        
        // 标题
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:15];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    // 图片
    self.imgView.frame = CGRectMake(17.5, 12.5, layoutAttributes.size.width - 38, layoutAttributes.size.height - 25);
    // 标题
    self.titleLabel.frame = CGRectMake(0, 70, layoutAttributes.size.width, 30);
}

- (void)setModel:(HZL_StoreModel *)model
{
    if (_model != model) {
        _model = model;
    }
    self.titleLabel.text = model.name;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.img]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
